﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Payroll.Biz.Legacy.Models
{
    public class DirectDepositMethod : IPaymentMethod
    {
        public string Bank { get; private set; }

        public string AccountNumber { get; private set; }

        public DirectDepositMethod(string bank, string accountNumber)
        {
            Bank = bank;
            AccountNumber = accountNumber;
        }

        public void Pay(Paycheck paycheck) { paycheck.Disposition = DispositionType.DIRECT; }

        public override string ToString()
        { return $"{{{nameof(Bank)}={Bank}, {nameof(AccountNumber)}={AccountNumber}}}"; }

        public override bool Equals(object obj)
        {
            return (obj is DirectDepositMethod method) &&
                (Bank == method.Bank) &&
                (AccountNumber == method.AccountNumber);
        }

        public override int GetHashCode()
        {
            int hashCode = -726221636;
            hashCode = (hashCode * (-1521134295)) + EqualityComparer<string>.Default.GetHashCode(Bank);
            hashCode = (hashCode * (-1521134295)) + EqualityComparer<string>.Default.GetHashCode(AccountNumber);
            return hashCode;
        }
    }
}
